package file;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        File dir = new File(".");
        FileFilter filter = new FileFilter() {
            public boolean accept(File file) {
                String name = file.getName();
                System.out.println("正在过滤的元素是" + name);
                return name.startsWith(".");
            }
        };
        File[] files = dir.listFiles(filter);
        System.out.println("当前目录下共：" + files.length + "个子项");

    }
}
